package Vista;
import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.BorderFactory;
import javax.swing.JButton;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;
import javax.swing.border.BevelBorder;


import Controlador.cIngredientes;
import Modelo.mCategoria;
import Modelo.mIngredientes;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class Ingredientes extends javax.swing.JDialog {
	private JLabel jLabel1;
	private JButton jButton1;
	private JTextField jTextField1;
	private JLabel jLabel2;
	private JTextField jTextField2;
	private JLabel jLabel3;
	private JLabel jLabel4;
	private JButton jButton5;
	private JTextField jTextField3;
	private JPanel jPanel1;
	private JButton jButton4;
	private JButton jButton3;
	private JButton jButton2;

	/**
	* Auto-generated main method to display this JDialog
	*/
	public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				JFrame frame = new JFrame();
				Ingredientes inst = new Ingredientes(frame);
				inst.setVisible(true);
			}
		});
	}
	
	public Ingredientes(JFrame frame) {
		super(frame);
		initGUI();
	}
	
	private void initGUI() {
		try {
			{
				getContentPane().setLayout(null);
				this.addWindowListener(new WindowAdapter() {
					public void windowOpened(WindowEvent evt) {
						System.out.println("this.windowOpened, event="+evt);
						//TODO add your code for this.windowOpened
						cIngredientes cIng = new cIngredientes(); 
						cIng.limpiar(jTextField1, jTextField2, jTextField3, jButton1, jButton2, jButton3);
					}
				});
				{
					jLabel1 = new JLabel();
					getContentPane().add(jLabel1);
					jLabel1.setText("Registro de Ingredientes");
					jLabel1.setBounds(32, 42, 252, 24);
					jLabel1.setFont(new java.awt.Font("Segoe UI",1,18));
				}
				{
					jButton2 = new JButton();
					getContentPane().add(jButton2);
					jButton2.setText("Modificar");
					jButton2.setBounds(95, 230, 76, 22);
					jButton2.setFont(new java.awt.Font("Segoe UI",0,9));
					jButton2.addActionListener(new ActionListener() {
						public void actionPerformed(ActionEvent evt) {
							System.out.println("jButton2.actionPerformed, event="+evt);
							//TODO add your code for jButton2.actionPerformed
							cIngredientes cIng = new cIngredientes(); 
							cIng.guardar(jTextField1, jTextField2, jTextField3, jButton1, jButton2, jButton3);

						}
					});
				}
				{
					jButton3 = new JButton();
					getContentPane().add(jButton3);
					jButton3.setText("Eliminar");
					jButton3.setBounds(169, 230, 75, 22);
					jButton3.setFont(new java.awt.Font("Segoe UI",0,9));
					jButton3.addActionListener(new ActionListener() {
						public void actionPerformed(ActionEvent evt) {
							System.out.println("jButton3.actionPerformed, event="+evt);
							//TODO add your code for jButton3.actionPerformed
							cIngredientes cIng = new cIngredientes(); 
							cIng.eliminar(jTextField1, jTextField2, jTextField3, jButton1, jButton2, jButton3);

						}
					});
				}
				{
					jButton4 = new JButton();
					getContentPane().add(jButton4);
					jButton4.setText("Salir");
					jButton4.setBounds(335, 230, 58, 22);
					jButton4.setFont(new java.awt.Font("Segoe UI",0,9));
					jButton4.addActionListener(new ActionListener() {
						public void actionPerformed(ActionEvent evt) {
							System.out.println("jButton4.actionPerformed, event="+evt);
							//TODO add your code for jButton4.actionPerformed
							dispose();
						}
					});
				}
				{
					jPanel1 = new JPanel();
					getContentPane().add(jPanel1);
					jPanel1.setBounds(32, 84, 349, 122);
					jPanel1.setBorder(BorderFactory.createEtchedBorder(BevelBorder.LOWERED));
					jPanel1.setLayout(null);
					{
						jTextField3 = new JTextField();
						jPanel1.add(jTextField3);
						jTextField3.setBounds(106, 79, 77, 20);
						
					}
					{
						jLabel4 = new JLabel();
						jPanel1.add(jLabel4);
						jLabel4.setText("Cantidad:");
						jLabel4.setBounds(19, 80, 75, 18);
					}
					{
						jLabel3 = new JLabel();
						jPanel1.add(jLabel3);
						jLabel3.setText("Descripcion:");
						jLabel3.setBounds(19, 48, 75, 18);
					}
					{
						jTextField2 = new JTextField();
						jPanel1.add(jTextField2);
						jTextField2.setBounds(106, 48, 210, 20);
						
					}
					{
						jLabel2 = new JLabel();
						jPanel1.add(jLabel2);
						jLabel2.setText("Codigo:");
						jLabel2.setBounds(19, 20, 75, 18);
					}
					{
						jTextField1 = new JTextField();
						jPanel1.add(jTextField1);
						jTextField1.setBounds(106, 20, 77, 20);
						
						jTextField1.addFocusListener(new FocusAdapter() {
							public void focusLost(FocusEvent evt) {
								System.out.println("jTextField1.focusLost, event="+evt);
								//TODO add your code for jTextField1.focusLost
								cIngredientes cIng = new cIngredientes(); 
								cIng.buscar(jTextField1, jTextField2, jTextField3, jButton1, jButton2, jButton3);

							}
						});
					}
				}
				{
					jButton5 = new JButton();
					getContentPane().add(jButton5);
					jButton5.setText("Cancelar");
					jButton5.setBounds(242, 230, 75, 22);
					jButton5.setFont(new java.awt.Font("Segoe UI",0,9));
					jButton5.addActionListener(new ActionListener() {
						public void actionPerformed(ActionEvent evt) {
							System.out.println("jButton5.actionPerformed, event="+evt);
							//TODO add your code for jButton5.actionPerformed
							cIngredientes cIng = new cIngredientes(); 
							cIng.limpiar(jTextField1, jTextField2, jTextField3, jButton1, jButton2, jButton3);

						}
					});
				}
				{
					jButton1 = new JButton();
					getContentPane().add(jButton1);
					jButton1.setText("Incluir");
					jButton1.setBounds(20, 230, 76, 22);
					jButton1.setFont(new java.awt.Font("Segoe UI",0,9));
					jButton1.addActionListener(new ActionListener() {
						public void actionPerformed(ActionEvent evt) {
							System.out.println("jButton1.actionPerformed, event="+evt);
							//TODO add your code for jButton1.actionPerformed
							cIngredientes cIng = new cIngredientes(); 
							cIng.guardar(jTextField1, jTextField2, jTextField3, jButton1, jButton2, jButton3);

						}
					});
				}
			}
			this.setSize(420, 316);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}
